package com.qf.controller;

import com.qf.pojo.resp.BaseResp;
import com.qf.utils.UploadImg;

import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RequestMapping("/base")
@RestController
@Api(tags = "图片上传")
public class Base2Controller {
    @Autowired
    UploadImg uploadImg;


    //上传
    @PostMapping("/upload")
    public BaseResp upload(@RequestParam("file")MultipartFile multipartFile){
        String upload = uploadImg.uploadImg(multipartFile);
        if (StringUtils.isEmpty(upload)){
                return new BaseResp().ERROR();
        }

        return new BaseResp(200,"success",upload);
    }
}
